﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using AutonomicComputingLibrary.Helpers;

namespace AutonomicComputingLibrary.MAPE
{
    class Plan
    {
        public static List<Guid> attemptedPlans = new List<Guid>();

        //test this
        public void SortPlans(string subsystem)
        {
            var xml = new XMLManager();

            foreach (var item in xml.SelectEntries(subsystem).OrderByDescending(b => b.Item2).Where(
                     item => !attemptedPlans.Contains(item.Item1)))
            {
                attemptedPlans.Add(item.Item1);
                SendForExec(item.Item3, item.Item4);
                break;
            }
        }

        private void SendForExec( string method, string _class)
        {
            var e = new Execute(GetClasses(_class), method);
        }


        public dynamic GetClasses(string fullclassname)
        {
            return  Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && t.FullName == fullclassname).FirstOrDefault();
            
        }
       
    }
}
